<div class="hrecipe-head">
  <h1 class="fn"><%=link_to h(@recipe.name), user_recipe_path(@recipe.author,@recipe) %></h1>
  <p class="category"><%= link_to @recipe.category.name, @recipe.category %></p> 

<% if @recipe.author? current_user %>
  <p class="actions">
    <%= link_to "#{image_tag 'edit.png', :alt => ''} editar", edit_user_recipe_path(@recipe.author, @recipe), :class => "edit" %>
    <%= link_to "#{image_tag 'delete.png', :alt => ''} eliminar", user_recipe_path(@recipe.author, @recipe), :confirm => '¿estás seguro?', :method => :delete, :class => "delete" %>
  </p>
<% end %>
</div>

<div id="recipe-sidebar" class="sidebar">
  <%= render :partial => "show_sidebar" %>  
</div>

<div class="hrecipe-main">
  <%= image_tag @recipe.photo.url(:large), :class => "photo", :alt => @recipe.name %>

<% unless @recipe.recipe_ingredients.blank? %>
  <h2 class="clearfix">ingredientes
    <% unless @recipe.num_persons.blank? %>
      <span class="num-persons">(para <span class="yield"><%=h @recipe.num_persons %></span> personas)</span>
    <% end %>
  </h2>
  <% if @recipe.recipe_ingredients.size <=  5 %>
    
    <ul class="ingredients">
      <% @recipe.recipe_ingredients.each do |ri|%>
        <li class="ingredient">
          <% unless ri.value.blank? %>
            <span class="value"><%= round ri.value %></span>
          <% end %>
          <% unless ri.value_type.blank? %>
            <span class="type"><%= h ri.value_type %></span>
            <span class="ft">de</span>
          <% end %>
          <%= h ri.ingredient.name %>
          <%= h ri.comment %>
          <% if ri.optional %>
            <span class="ft">(opcional)</span>
          <% end %>
        </li>
      <% end %>      
    </ul>

  <% else %>
    <% group_size = (@recipe.recipe_ingredients.size + 1) / 2 %>
    <% @recipe.recipe_ingredients.in_groups_of(group_size).each do |ri_group| %>
      <ul class="ingredients">
        <% ri_group.each do |ri| %>
          <% unless ri.nil? %>
            <li class="ingredient">
              <% unless ri.value.blank? %>
                <span class="value"><%= round ri.value %></span>
              <% end %>
              <% unless ri.value_type.blank? %>
                <span class="type"><%= h ri.value_type %></span>
                <span class="ft">de</span>
              <% end %>
              <%= h ri.ingredient.name %>
              <%= h ri.comment %>
              <% if ri.optional %>
                <span class="ft">(opcional)</span>
              <% end %>
            </li>
          <% end %>
        <% end %>
      </ul>
    <% end %>      

  <% end %>
<% end %>

<h2 class="clear">preparación
  <% unless @recipe.cook_time.blank? %>
    <span class="duration">(<span class="value-title" title="@recipe.cook_time"></span><%=h @recipe.cook_time %> min)</span>
  <% end %>
</h2>

<div class="instructions">
  <%= simple_format(h(@recipe.directions)) %>
</div>

<%= render :partial => "comments" %>
<%= will_paginate @comments %>

</div>
